<?php

/**
 * sfGuardGroup filter form.
 *
 * @package    ##PROJECT_NAME##
 * @subpackage filter
 * @author     ##AUTHOR_NAME##
 * @version    SVN: $Id: sfGuardGroupFormFilter.class.php 12896 2008-11-10 19:02:34Z fabien $
 */
class sfGuardGroupFormFilter extends BasesfGuardGroupFormFilter
{
  public function configure()
  {
    unset($this['sf_guard_user_group_list']);

    $this->widgetSchema['sf_guard_group_permission_list']->setLabel('Permissions');
  }
  
    public function setup()
  {parent::setup();
    $this->setWidgets(array(
      'name'                           => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'description'                    => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'sf_guard_user_group_list'       => new sfWidgetFormPropelChoice(array('model' => 'sfGuardUser', 'add_empty' => 'Seleccione un grupo...')),
      'sf_guard_group_permission_list' => new sfWidgetFormPropelChoice(array('model' => 'sfGuardPermission', 'add_empty' => 'Seleccione un permiso...')),
    ));

    $this->setValidators(array(
      'name'                           => new sfValidatorString(array('required' => false)),
      'description'                    => new sfValidatorString(array('required' => false)),
      'sf_guard_user_group_list'       => new sfValidatorPropelChoice(array('model' => 'sfGuardUser', 'required' => false)),
      'sf_guard_group_permission_list' => new sfValidatorPropelChoice(array('model' => 'sfGuardPermission', 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('sf_guard_group_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    
  }


    public function addNameColumnCriteria(Criteria $criteria, $field, $values) {

        if(!empty($values)){
            $criteria->add(sfGuardGroupPeer::NAME, $values.'%', Criteria::LIKE);
        }
    }
}
